﻿<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:dataInput="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data.Input"  
    xmlns:customUI="clr-namespace:MyFloridaHouse.libSvUIControls;assembly=libSvUIControls">

    <DataTemplate  x:Key="DataTemplateRegionFillCriteria" >
        <Border  Background="{Binding isSelected,  Converter={StaticResource ConvertActiveBrushFromBool}}" Width="250" 
                                                 BorderBrush="{Binding isQueryCriteria,  Converter={StaticResource ConvertIndicatorBrushFromBool}}" 
                                                         BorderThickness="2" CornerRadius="10"  >
            <StackPanel Orientation="Vertical" VerticalAlignment="Stretch">
                <StackPanel Orientation="Horizontal" HorizontalAlignment="Stretch">
                    <CheckBox           Tag="{Binding}" IsChecked="{Binding isQueryCriteria, Mode=TwoWay}" Margin="2" HorizontalAlignment="Left" VerticalAlignment="Center" />
                    <dataInput:Label    Tag="{Binding}" Content="{Binding criteriaHeader}"  ToolTipService.ToolTip="{Binding description}" Style="{StaticResource lblHeaderStyle}" HorizontalAlignment="Left" VerticalAlignment="Center" />
                </StackPanel>
                <Border  Visibility="{Binding isQueryCriteria, Converter={StaticResource ConvertVisibilityFromBool}}">
                <Border Visibility="{Binding criteriaType, Converter={StaticResource ConvertVisibilityFromCriteriaType}, ConverterParameter=Total}"
                                                         >
                    <Grid Background="#FFAADFE5" >
                        <Grid.RowDefinitions>
                            <RowDefinition Height="auto" />
                            <RowDefinition Height="auto" />
                            <RowDefinition Height="auto" />
                        </Grid.RowDefinitions>

                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>

                        <TextBox            Grid.Row="0" Grid.Column="0"  Text="{Binding queryMin, Mode=TwoWay}" HorizontalAlignment="Left" Margin="5 5 0 2"/>
                        <TextBox            Grid.Row="0" Grid.Column="1"  Text="{Binding queryMax, Mode=TwoWay}" HorizontalAlignment="Right" Margin="0 5 5 2" />
                        <customUI:RangeSlider Grid.Row="1" Grid.ColumnSpan="2" Grid.Column="0" x:Name="TotalCriteriaRangeSlider" Minimum="{Binding pctValueMin, Mode=TwoWay}" LowerValue="{Binding pctQueryMin, Mode=TwoWay}" UpperValue="{Binding pctQueryMax, Mode=TwoWay}" Maximum="{Binding pctValueMax, Mode=TwoWay}" HorizontalAlignment="Stretch" ></customUI:RangeSlider>
                        <dataInput:Label    Grid.Row="2" Grid.Column="0" Tag="{Binding}" Content="{Binding valueMin}"  Style="{StaticResource lblHeaderStyle}"   HorizontalAlignment="Left" />
                        <dataInput:Label    Grid.Row="2" Grid.Column="1" Tag="{Binding}" Content="{Binding valueMax}"  Style="{StaticResource lblHeaderStyle}"    HorizontalAlignment="Right"/>

                    </Grid>
                </Border>
                </Border>
                    <Border Visibility="{Binding criteriaType, Converter={StaticResource ConvertVisibilityFromCriteriaType}, ConverterParameter=Percent}">
                    <Border  Visibility="{Binding isQueryCriteria, Converter={StaticResource ConvertVisibilityFromBool}}">
                        <Grid Background="#FF7ADDE0">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="auto" />
                                <RowDefinition Height="auto" />
                                <RowDefinition Height="auto" />
                            </Grid.RowDefinitions>

                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>

                            <TextBox            Grid.Row="0" Grid.Column="0"  Text="{Binding queryMin, Mode=TwoWay}" HorizontalAlignment="Left" Margin="5 5 0 2"/>
                            <TextBox            Grid.Row="0" Grid.Column="1"  Text="{Binding queryMax, Mode=TwoWay}" HorizontalAlignment="Right" Margin="0 5 5 2" />
                            <customUI:RangeSlider Grid.Row="1" Grid.ColumnSpan="2" Grid.Column="0" x:Name="percentCriteriaRangeSlider" Minimum="0" LowerValue="{Binding pctQueryMin, Mode=TwoWay}" UpperValue="{Binding pctQueryMax, Mode=TwoWay}" Maximum="100" HorizontalAlignment="Stretch" ></customUI:RangeSlider>
                            <dataInput:Label    Grid.Row="2" Grid.Column="0" Tag="{Binding}" Content="{Binding valueMin}"  Style="{StaticResource lblHeaderStyle}"   HorizontalAlignment="Left" />
                            <dataInput:Label    Grid.Row="2" Grid.Column="1" Tag="{Binding}" Content="{Binding valueMax}"  Style="{StaticResource lblHeaderStyle}"    HorizontalAlignment="Right"/>

                        </Grid>
                    </Border>
                </Border>

                <Border Visibility="{Binding criteriaType, Converter={StaticResource ConvertVisibilityFromCriteriaType}, ConverterParameter=TotalDifference}" >
                    <Border  Visibility="{Binding isQueryCriteria, Converter={StaticResource ConvertVisibilityFromBool}}">

                        <Grid Background="#FF7AC2C4" >
                            <Grid.RowDefinitions>
                                <RowDefinition Height="auto" />
                                <RowDefinition Height="auto" />
                                <RowDefinition Height="auto" />
                            </Grid.RowDefinitions>

                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>

                            <TextBox            Grid.Row="0" Grid.Column="0"  Text="{Binding queryMin, Mode=TwoWay}" HorizontalAlignment="Left" Margin="5 5 0 2"/>
                            <TextBox            Grid.Row="0" Grid.Column="1"  Text="{Binding queryMax, Mode=TwoWay}" HorizontalAlignment="Right" Margin="0 5 5 2" />
                            <customUI:RangeSlider Grid.Row="1" Grid.ColumnSpan="2" Grid.Column="0" x:Name="totalDifferenceCriteriaRangeSlider" Minimum="0" LowerValue="{Binding pctQueryMin, Mode=TwoWay}" UpperValue="{Binding pctQueryMax, Mode=TwoWay}" Maximum="100" HorizontalAlignment="Stretch" ></customUI:RangeSlider>
                            <dataInput:Label    Grid.Row="2" Grid.Column="0" Tag="{Binding}" Content="{Binding valueMin}"  Style="{StaticResource lblHeaderStyle}"   HorizontalAlignment="Left" />
                            <dataInput:Label    Grid.Row="2" Grid.Column="1" Tag="{Binding}" Content="{Binding valueMax}"  Style="{StaticResource lblHeaderStyle}"    HorizontalAlignment="Right"/>

                        </Grid>
                    </Border>
                </Border>

                <Border Visibility="{Binding criteriaType, Converter={StaticResource ConvertVisibilityFromCriteriaType}, ConverterParameter=TotalDifferenceRelativeMagnitude}" >
                    <Border  Visibility="{Binding isQueryCriteria, Converter={StaticResource ConvertVisibilityFromBool}}">

                        <Grid Background="#FF7AC2C4" >
                            <Grid.RowDefinitions>
                                <RowDefinition Height="auto" />
                                <RowDefinition Height="auto" />
                                <RowDefinition Height="auto" />
                            </Grid.RowDefinitions>

                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>

                            <TextBox            Grid.Row="0" Grid.Column="0"  Text="{Binding queryMin, Mode=TwoWay}" HorizontalAlignment="Left" Margin="5 5 0 2"/>
                            <TextBox            Grid.Row="0" Grid.Column="1"  Text="{Binding queryMax, Mode=TwoWay}" HorizontalAlignment="Right" Margin="0 5 5 2" />
                            <customUI:RangeSlider Grid.Row="1" Grid.ColumnSpan="2" Grid.Column="0" x:Name="totalDifferenceRelMagnitudeCriteriaRangeSlider" Minimum="0" LowerValue="{Binding pctQueryMin, Mode=TwoWay}" UpperValue="{Binding pctQueryMax, Mode=TwoWay}" Maximum="100" HorizontalAlignment="Stretch" ></customUI:RangeSlider>
                            <dataInput:Label    Grid.Row="2" Grid.Column="0" Tag="{Binding}" Content="{Binding valueMin}"  Style="{StaticResource lblHeaderStyle}"   HorizontalAlignment="Left" />
                            <dataInput:Label    Grid.Row="2" Grid.Column="1" Tag="{Binding}" Content="{Binding valueMax}"  Style="{StaticResource lblHeaderStyle}"    HorizontalAlignment="Right"/>

                        </Grid>
                    </Border>
                </Border>
                <Border Visibility="{Binding criteriaType, Converter={StaticResource ConvertVisibilityFromCriteriaType}, ConverterParameter=PercentDifference}" >
                    <Border  Visibility="{Binding isQueryCriteria, Converter={StaticResource ConvertVisibilityFromBool}}">

                        <Grid Background="#FF43CAE4" >
                            <Grid.RowDefinitions>
                                <RowDefinition Height="auto" />
                                <RowDefinition Height="auto" />
                                <RowDefinition Height="auto" />
                            </Grid.RowDefinitions>

                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>

                            <TextBox            Grid.Row="0" Grid.Column="0"  Text="{Binding queryMin, Mode=TwoWay}" HorizontalAlignment="Left" Margin="5 5 0 2"/>
                            <TextBox            Grid.Row="0" Grid.Column="1"  Text="{Binding queryMax, Mode=TwoWay}" HorizontalAlignment="Right" Margin="0 5 5 2" />
                            <customUI:RangeSlider Grid.Row="1" Grid.ColumnSpan="2" Grid.Column="0" x:Name="percentDifferenceCriteriaRangeSlider" Minimum="0" LowerValue="{Binding pctQueryMin, Mode=TwoWay}" UpperValue="{Binding pctQueryMax, Mode=TwoWay}" Maximum="100" HorizontalAlignment="Stretch" ></customUI:RangeSlider>
                            <dataInput:Label    Grid.Row="2" Grid.Column="0" Tag="{Binding}" Content="{Binding valueMin}"  Style="{StaticResource lblHeaderStyle}"   HorizontalAlignment="Left" />
                            <dataInput:Label    Grid.Row="2" Grid.Column="1" Tag="{Binding}" Content="{Binding valueMax}"  Style="{StaticResource lblHeaderStyle}"    HorizontalAlignment="Right"/>

                        </Grid>
                    </Border>
                </Border>
            </StackPanel>
        </Border>
    </DataTemplate>

</ResourceDictionary>
